package com.prp.gwt.client.widgets.user.friend;

import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.prp.gwt.client.vo.UserList;

public class MyRecommendationList extends VerticalPanel{

	private static MyRecommendationList instance;
	private HTML title =new HTML("邻友推荐");
	private int USER_PER_ROW = 2;
	private FlexTable table = new FlexTable();
	
	public static MyRecommendationList getInstance(){
		return instance;
	}
	
	public MyRecommendationList(){
		instance = this;
		add(title);
		add(table);
		title.addStyleName("friend-sidebar-title");
	}
	
	public void load(UserList userList){
		table.clear();
		title.setHTML("你有" + userList.size() + "个邻友推荐");
		for(int i = 0; i < userList.size(); i++)
			table.setWidget(i/USER_PER_ROW, i%USER_PER_ROW, new RecommendItem(userList.get(i)));
	}
	
}
